

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Project List</title>
    </head>
    <body>
        <div class="undernav">
            <span class="menuButton"><g:link class="create" action="create">New Project</g:link></span>
           
            <!-- This is the help button. -->
            <%  def help = Help.findByNameAndLanguage("project_list", session.language)
            def helplink = createLink(action:'show', controller:'help', id: help.id )%>
            <a href="#" onClick="MyWindow=window.open('${helplink}','Help','width=350,height=450'); return false;">Help</a>
            <!-- This is the end of the help button. -->

        </div>
        <div class="body">
            <g:btnMode mode="${session.mode}" currentView="list" currentController="project"></g:btnMode>
            <h1>Project List</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                   	        <g:sortableColumn property="activityId" title="Activity Id" />
                        
                   	        <g:sortableColumn property="name" title="Name" />
                        
                   	        <g:sortableColumn property="description" title="Description" />
                                <g:sortableColumn property="area" title="Area" />
                                <!-- <th>Area</th>-->
                                <g:sortableColumn property="startDate" title="Start Date" />
                   	        <g:sortableColumn property="endDate" title="End Date" />
                                <th>Status</th>
                                <th>Current Balance</th>
                                <th>Incoming Balance</th>
                        
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${projectInstanceList}" status="i" var="projectInstance">
                      <g:if test="${ModeAccess.isAvailableInCurrentMode(session.mode,projectInstance.mode)}">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td>
                                <g:link action="show" id="${projectInstance.id}">
                                 ${fieldValue(bean:projectInstance, field:'activityId')}
                                </g:link>
                            </td>
                        
                            <td>
                                <g:link action="show" id="${projectInstance.id}">
                                  ${fieldValue(bean:projectInstance, field:'name')}
                                </g:link>
                            </td>
                        
                            <td>
                               <g:link action="show" id="${projectInstance.id}">
                                  ${fieldValue(bean:projectInstance, field:'description')}
                               </g:link>    
                            </td>
                        
                            <td>
                                 <g:link action="show" id="${projectInstance.id}">
                                   ${fieldValue(bean:projectInstance, field:'area')}
                                 </g:link>
                            </td>
                            <td>
                              <g:link action="show" id="${projectInstance.id}">
                                <g:formatDate date="${projectInstance.startDate}" format="yyyy-MM-dd"/>
                              </g:link>
                            </td>

                            <td>
                              <g:link action="show" id="${projectInstance.id}">
                                <g:formatDate date="${projectInstance.endDate}" format="yyyy-MM-dd"/>
                              </g:link>
                            </td>

                            <td>
                              <g:link action="show" id="${projectInstance.id}">
                                ${projectInstance.calcStatus()}
                              </g:link>
                            </td>
                            <td>
                              <g:link action="show" id="${projectInstance.id}">
                                ${projectInstance.calcCurrentBalance()}
                              </g:link>
                            </td>
                            <td>
                              <g:link action="show" id="${projectInstance.id}">
                                ${projectInstance?.currentBudget()?.calcBalance()}
                              </g:link>
                            </td>
                        
                        </tr>
                       </g:if> 
                      
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${projectInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
